#ifndef PLAIN_TEXT_MESSAGE_H_13MAR2012
#define PLAIN_TEXT_MESSAGE_H_13MAR2012

#include <string>

#include "message.h"

namespace connection
{

class PlainTextMessage : public virtual Message
{
public:
	PlainTextMessage( const std::string& sMessage );
	const std::string& GetMessage() const throw();

	~PlainTextMessage() throw()
	{
	}

private:
	std::string m_sMessage;
};

class PlainTextSerializer : public virtual MessageSerializer
{
public:
	virtual std::string Serialize( Message* pMessage )
	{
		PlainTextMessage* pPlainTextMessage = dynamic_cast< PlainTextMessage* >( pMessage );
		if( NULL == pPlainTextMessage )
		{
			//TODO use special exception
			return "";
		}

		return pPlainTextMessage->GetMessage();
	}

	virtual Message* Deserialize( const std::string& sMessage )
	{
		return new PlainTextMessage( sMessage );
	}
}; // class PlainTextSerializer

} // namespace connection

#endif
